<%@ page contentType="text/html; charset=utf-8" language="java"%>
<%@ include file="/common/index.jsp"%>
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title>Document</title>
	<script language="javascript" src="<%=basePath %>/js/jquery-1.7.1.min.js"></script>
	<link rel="stylesheet" type="text/css" href="<%=basePath %>/css/css.css">
	<style type="text/css">
	
		.color1{
			background: #fe8f3f;
		}
		
		.color2{
			background: #869AB1;
		}
		
	</style>
</head>
<%
	String phoneNum = request.getParameter("phoneNum");
%>
<body>
	<div class="wrapper">
		<h2><a onclick="window.location.href='<%=basePath %>/manager/batchGame/selectForApp.shtml?phoneNum=<%=phoneNum %>&game_flag=<s:property value="game_flag"/>&fuli_type=<s:property value="fuli_type"/>';" class="spec1"> < </a>福利<a onclick="window.location.href='<%=basePath %>/manager/batchGame/selectMyGameApp.shtml?phoneNum=<%=phoneNum %>';" class="spec2">我的福利</a></h2>
		<div class="main1">
			<dl>
				<dt>
					<a onclick="">
						<img src="<s:property value="gameRefBatch.imgSrc"/>">
						<p>剩余<span><s:property value="gameRefBatch.ncount-gameRefBatch.useCount"/></span>个</p>
					</a>
				</dt>
				<dd>
					<h5><s:property value="gameRefBatch.title"/></h5>
					<p>数量共计<s:property value="gameRefBatch.ncount"/>个</p>
				</dd>
			</dl>
			<s:if test="gameRefBatch.flag==1">
				<h6><a id="tryGet" class="color2" >您已领取过</a></h6>
			</s:if>
			<s:else>
				<s:set name="nowTime" value="new java.util.Date()"></s:set>
				<s:set name="lessTime" value="gameRefBatch.endtime"></s:set>
				<s:if test='#lessTime != null && #lessTime.getTime()>#nowTime.getTime()'>
					<s:if test="gameRefBatch.ncount-gameRefBatch.useCount>0">
						<h6><a id="tryGet" class="color1" onclick="toTryGetFuli('<s:property value="gameRefBatch.batchCode"/>')" >试试手气</a></h6>	
					</s:if>
					<s:else>
						<h6><a id="tryGet" class="color2" >剩余0个</a></h6>
					</s:else>						
				</s:if>
				<s:else>
					<h6><a id="tryGet" class="color2" >已结束</a></h6>
				</s:else>
			</s:else>
		</div>
		<div class="main2">
			<p><s:property value="gameRefBatch.descStr"/></p>
		</div>
		 
		 
	</div>
</body>


<script language="javascript">

	function toTryGetFuli(batchCode){
		var url = "<%=basePath %>/manager/batchGame/toTryGetFuli.shtml";
		var param = {batchCode:batchCode,phoneNum:'<%=phoneNum%>'};
		$.post(url 
			,param 
				,function(rs) {
					if(rs.code==0){
						alert('恭喜您,领取成功');
						window.location.reload(true); 
					}else{
						alert(rs.info);
					}
				}
		   ,'json');
	}

</script>
	
</html>